<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">
		<title>修改宝宝资料</title>
		<link rel="stylesheet" href="../../css/base.css" />
		<link rel="stylesheet" href="../../css/common.css" />
		<!-- Bootstrap Core CSS -->
		<link href="../../sbadmin/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
		<!-- MetisMenu CSS -->
		<link href="../../sbadmin/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
		<!-- DataTables CSS -->
		<link href="../../sbadmin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">
		<!-- Custom CSS -->
		<link href="../../sbadmin/dist/css/sb-admin-2.css" rel="stylesheet">
		<!-- Custom Fonts -->
		<link href="../../sbadmin/bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" href="../../css/jquery.datetimepicker.css" />
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
	<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
		<style>
			body {
				padding: 0 15px !important;
			}
		</style>
	</head>

	<body style="background:#FFF;">
		<div class="comm-tt-font pr">
			会员信息 > 会员详情 > 修改宝宝资料
		</div>
		<div class="zl-ccbox">
			<div class="zl-cctt">
				<ul class="zl-list-ul clb">
					<li>
						<a href="personalMsg.html">个人资料</a>
					</li>
					<li>
						<a href="babyMsg.html" class="cur">宝宝资料</a>
					</li>
					<li>
						<a href="order.html">订单</a>
					</li>
				</ul>
			</div>
			<div class="zl-cccc pr">
				<div class="edit-item clb">
					<div class="edit-item-tt fl"><em>*</em>姓名：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" id="bbName" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl"><em>*</em>小名：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" id="bbXname" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl">性别：</div>
					<div class="edit-item-cc fl ml10">
						<div class="sexbox fl" id="nan">男</div>
						<div class="sexbox fl" id="nv">女</div>
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl">生日：</div>
					<div class="edit-item-cc fl ml10">
						<input type="text" class="edit-input" style="width: 200px;" id="bbBir" />
					</div>
				</div>
				<div class="edit-item clb">
					<div class="edit-item-tt fl"></div>
					<div class="edit-item-cc fl ml10">
						<a href="babyMsg.html" class="fl commqx-btn">取消</a>
						<a href="javascript:void(0);" class="fl commqr-btn ml15" id="editBB">确定</a>
					</div>
				</div>
			</div>
		</div>

		<!-- jQuery -->
		<script src="../../sbadmin/bower_components/jquery/dist/jquery.min.js"></script>
		<!-- Bootstrap Core JavaScript -->
		<script src="../../sbadmin/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<!-- Metis Menu Plugin JavaScript -->
		<script src="../../sbadmin/bower_components/metisMenu/dist/metisMenu.min.js"></script>
		<!-- DataTables JavaScript -->
		<script src="../../sbadmin/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
		<script src="../../sbadmin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
		<!-- Custom Theme JavaScript -->
		<script src="../../sbadmin/dist/js/sb-admin-2.js"></script>
		<script src="../../js/layer/layer.js"></script>
		<script type="text/javascript" src="../../js/common.js"></script>
		<script type="text/javascript" src="../../js/jquery.datetimepicker.full.js"></script>
		<!-- Page-Level Demo Scripts - Tables - Use for reference -->
	</body>
	<script>
		$(function() {
			$.datetimepicker.setLocale('ch');
			$('#bbBir').datetimepicker({
				lang: "ch", //语言选择中文 注：旧版本 新版方法：$.datetimepicker.setLocale('ch');
				format: 'Y-m-d',
				timepicker: false, //关闭时间选项
				yearStart: 2000, //设置最小年份
				yearEnd: 2050, //设置最大年份
				todayButton: false, //关闭选择今天按钮
				step: 5,
				//  startDate: enddate + "-" + "01"
			});
			$(".sexbox").click(function() {
				$(this).addClass("cur").siblings().removeClass("cur");
			})
			var bbId = localStorage.getItem("bbId");
			$.ajax({
				url: "https://order.wz1996.wang/wzbg/kid/one/" + bbId,
				type: 'get',
				contentType: 'application/json',
				beforeSend: function(request) {
					request.setRequestHeader("token", localStorage.getItem("token"));
				},
				success: function(data) {
					if(data.code == "1") {
						$("#bbName").val(data.data.name);
						$("#bbXname").val(data.data.alias);
						if(data.data.sex == "1") {
							$("#nan").addClass("cur");
						} else {
							$("#nv").addClass("cur");
						}
						$("#bbBir").val(data.data.birthday.split(" ")[0]);
					} else if(data.code == "-1") {
						layar(data.msg);
						setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
					} else {
						layar(data.msg);
					}
				},
				error: function(e) {
					errcode(e);
				}
			});

			$("#editBB").click(function() {
				var bbName = $("#bbName").val();
				var bbXname = $("#bbXname").val();
				var bbSex = "";
				if($("#nan").hasClass("cur")) {
					bbSex = "1"
				} else {
					bbSex = "0"
				}
				var bbBir = $("#bbBir").val() + " 00:00:00";
				var post_data = {
					"name": bbName,
					"alias": bbXname,
					"sex": bbSex,
					"birthday": bbBir,
					"id": bbId
				}
				$.ajax({
					url: "https://order.wz1996.wang/wzbg/kid/update",
					type: 'PUT',
					contentType: 'application/json',
					data: JSON.stringify(post_data),
					beforeSend: function(request) {
						request.setRequestHeader("token", localStorage.getItem("token"));
					},
					success: function(data) {
						if(data.code == "1") {
							layar("修改成功！");
							setTimeout("window.location.href='babyMsg.html'", 1000)
						} else if(data.code == "-1") {
							layar(data.msg);
							setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
						} else {
							layar(data.msg);
						}
					},
					error: function(e) {
						errcode(e);
					}
				});

			})

		})
	</script>

</html>